import com.jediflasher.game_server.data.WorldData
import com.jediflasher.game_server.util.log.Logger
import java.io.IOException
import java.lang.Thread
import java.net.ServerSocket

/**
 * User: Obi
 * Date: 11.07.11
 * Time: 22:32
 */

object Server {

	def main(args: Array[String]) {
		Logger.init();

		val policyPort = 7180;
		val port = 7181;
		try {
			val listener = new ServerSocket(port);
			val policyListener = new ServerSocket(policyPort);

			new Thread(
				new Runnable {
					def run() {
						while (true) {
							new SocketPolicyHandler(policyListener.accept()).start();
						}
					}
				}
			).start();

			val worldData = new WorldData();
			new Thread(
				new Runnable {
					def run() {
						while (true) {
							new SocketHandler(listener.accept(), worldData).start();
						}
					}
				}
			).start();
		}
		catch {
			case e: IOException =>
				System.err.println("Could not listen on port: " + port + ".");
				System.exit(-1);
		}
	}

}